Skip to main content

@pexip/peer-connection-stats

Enumerations

Interfaces

Type Aliases

AnyStats

Ƭ AnyStats: CandidatePair | Codec | InboundAudio | InboundVideo | OutboundAudio | OutboundVideo | RTCStats | Remote | Stream | Track | Transport


AudioQualityStats

Ƭ AudioQualityStats: [number, number][]


CallPacketsStats

Ƭ CallPacketsStats: PacketsStats


CallQualityStats

Ƭ CallQualityStats: AudioQualityStats | VideoQualityStats


InboundAudioMetrics

Ƭ InboundAudioMetrics: Metrics


InboundVideoMetrics

Ƭ InboundVideoMetrics: VideoMetrics


NormalizedRTCStats

Ƭ NormalizedRTCStats: InboundAudioMetrics | InboundVideoMetrics | OutboundAudioMetrics | OutboundVideoMetrics


OutboundAudioMetrics

Ƭ OutboundAudioMetrics: Metrics


OutboundVideoMetrics

Ƭ OutboundVideoMetrics: VideoMetrics & { averagePacketSendDelay?: number ; totalPacketSendDelay?: number }


PacketsStats

Ƭ PacketsStats: [number, number][]


VideoQualityStats

Ƭ VideoQualityStats: number[]

Variables

STATS_SIZE

Const STATS_SIZE: 60

Functions

addDeltaStats

addDeltaStats(newStats, cache): readonly [{ bitrate?: number ; bytesTransmitted?: number ; codec?: string ; jitter?: number ; kind: "audio" | "video" ; packetsLost: number ; packetsTransmitted: number ; recentPercentageLost?: number ; roundTripTime?: number ; timestamp?: number ; totalPercentageLost?: number ; type: "inbound-rtp" | "outbound-rtp" } | { bitrate?: number ; bytesTransmitted?: number ; codec?: string ; framesPerSecond?: number ; jitter?: number ; kind: "audio" | "video" ; packetsLost: number ; packetsTransmitted: number ; recentPercentageLost?: number ; resolution?: string ; resolutionHeight?: number ; resolutionWidth?: number ; roundTripTime?: number ; timestamp?: number ; totalPercentageLost?: number ; type: "inbound-rtp" | "outbound-rtp" } | { averagePacketSendDelay?: number ; bitrate?: number ; bytesTransmitted?: number ; codec?: string ; framesPerSecond?: number ; jitter?: number ; kind: "audio" | "video" ; packetsLost: number ; packetsTransmitted: number ; recentPercentageLost?: number ; resolution?: string ; resolutionHeight?: number ; resolutionWidth?: number ; roundTripTime?: number ; timestamp?: number ; totalPacketSendDelay?: number ; totalPercentageLost?: number ; type: "inbound-rtp" | "outbound-rtp" }, Quality, CallQualityStats]

Parameters

NameType
newStatsNormalizedRTCStats
cacheCacheStats

Returns

readonly [{ bitrate?: number ; bytesTransmitted?: number ; codec?: string ; jitter?: number ; kind: "audio" | "video" ; packetsLost: number ; packetsTransmitted: number ; recentPercentageLost?: number ; roundTripTime?: number ; timestamp?: number ; totalPercentageLost?: number ; type: "inbound-rtp" | "outbound-rtp" } | { bitrate?: number ; bytesTransmitted?: number ; codec?: string ; framesPerSecond?: number ; jitter?: number ; kind: "audio" | "video" ; packetsLost: number ; packetsTransmitted: number ; recentPercentageLost?: number ; resolution?: string ; resolutionHeight?: number ; resolutionWidth?: number ; roundTripTime?: number ; timestamp?: number ; totalPercentageLost?: number ; type: "inbound-rtp" | "outbound-rtp" } | { averagePacketSendDelay?: number ; bitrate?: number ; bytesTransmitted?: number ; codec?: string ; framesPerSecond?: number ; jitter?: number ; kind: "audio" | "video" ; packetsLost: number ; packetsTransmitted: number ; recentPercentageLost?: number ; resolution?: string ; resolutionHeight?: number ; resolutionWidth?: number ; roundTripTime?: number ; timestamp?: number ; totalPacketSendDelay?: number ; totalPercentageLost?: number ; type: "inbound-rtp" | "outbound-rtp" }, Quality, CallQualityStats]


calculateQuality

calculateQuality(stats): Quality

Parameters

NameType
statsnumber | [number, number]

Returns

Quality


createResolver

createResolver(statsReport): Object

The WebRTC stats are given to us as a flat structure (an array of objects that contain id-fields pointing to other objects in the same array).

This class takes such an array as input and can expand an entry so that references become nested objects.

https://www.w3.org/TR/webrtc-stats/#summary https://www.w3.org/TR/webrtc-stats/#rtctatstype-*

Parameters

NameType
statsReportAnyStats[]

Returns

Object

NameType
expand(audioIn: InboundAudio) => InboundAudio(audioOut: OutboundAudio) => OutboundAudio(videoIn: InboundVideo) => InboundVideo(videoOut: OutboundVideo) => OutboundVideo

createStatsCollector

createStatsCollector(«destructured»): StatsCollector

Creates stats collector

Parameters

NameType
«destructured»StatsCollectorOptions

Returns

StatsCollector

{function to reset stats window, cleanup func}


createStatsSignals

createStatsSignals(scope?): StatsSignals

Create and return all required and optional (if specified with more), signals for infinity client to work

See

  • Signal
  • InfinitySignalsOptional

The following signals created by default

  • 'onConnected',
  • 'onAnswer',
  • REQUIRED_STATS_SIGNAL_KEYS

Parameters

NameTypeDefault valueDescription
scopestring''any scope prefix for the generated signal name,

Returns

StatsSignals


getQuality

getQuality(stats): Object

Parameters

NameType
statsCallQualityStats

Returns

Object

NameType
goodOrOkQualitynumber
qualityQuality
qualityOverTimeQuality[]

inboundAudio

inboundAudio(statsData): Metrics

Normalize inbound audio stats

See

InboundAudio

Parameters

NameTypeDescription
statsDataInboundAudioRaw inbound audio stats

Returns

Metrics

normalized stats for inbound audio from PeerConnection


inboundVideo

inboundVideo(statsData): VideoMetrics

Normalize inbound video stats

See

InboundVideo

Parameters

NameTypeDescription
statsDataInboundVideoRaw inbound video stats

Returns

VideoMetrics

normalized stats for inbound video from PeerConnection


outboundAudio

outboundAudio(statsData): Metrics

Normalize outbound audio stats

See

OutboundAudio

Parameters

NameTypeDescription
statsDataOutboundAudioRaw outbound audio stats

Returns

Metrics

normalized stats for outbound audio from PeerConnection


outboundVideo

outboundVideo(statsData): OutboundVideoMetrics

Normalize outbound video stats

See

OutboundVideo

Parameters

NameTypeDescription
statsDataOutboundVideoRaw outbound video stats

Returns

OutboundVideoMetrics

normalized stats for outbound video from PeerConnection


statsFrom

statsFrom(statsReports): undefined | Metrics

Normalize stats into inbound and outbound video and audio stats

Parameters

NameTypeDescription
statsReportsAnyStats[]reports to for mapping

Returns

undefined | Metrics

normalized stats for inbound, outbound audio and video


statsFromRTCPeer

statsFromRTCPeer(rtcPeer): Promise<NormalizedRTCStats>

Gets raw stats from peerConnection and normalized them

https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_Statistics_API

A RTCPeerConnection has getStats()

  • getStats() returns promise which resolve to a RTCStatsReport
  • RTCStatsReport behaves like an array of RTCStats objects, or more specific RTCRtpStreamStats objects

https://developer.mozilla.org/en-US/docs/Web/API/RTCStatsReport https://developer.mozilla.org/en-US/docs/Web/API/RTCStats https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpStreamStats

Parameters

NameType
rtcPeerObject
rtcPeer.getStats(selector?: null | MediaStreamTrack) => Promise<RTCStatsReport>

Returns

Promise<NormalizedRTCStats>